#include <algorithm>
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <istream>
#include <set>
using ll = int64_t;

const ll maxn = 1e4+5;
ll n,a[maxn],mina=4e9+7,ans;

int main(){
    std::iostream::sync_with_stdio(false);
    std::cin.tie(nullptr);

    std::cin>>n;
    for(ll i=1;i<=n;i++){
        std::cin>>a[i];
        mina=std::min(mina,a[i]);
    }
    std::sort(a+1,a+1+n);
    n=std::unique(a+1,a+1+n)-(a+1);
    if(n<4){
        std::cout<< (mina/4)*(mina/4+1)/2 <<"\n";
        return 0;
    }
    std::set<ll> yz;
    for(ll i=1;i<=4;i++){
        for(ll j=i+1;j<=4;j++){
            if(i==j)continue;
            ll now = std::abs(a[i]-a[j]);
            for(ll k=1;k*k<=now;k++){
                if(now%k==0){
                    yz.insert(k);
                    yz.insert(now / k); 
                }
            }
        }
    }
    std::set<ll> sl;
    for(const ll l:yz){
        if (l == 0) continue;
        if(l*4>mina)continue;
        std::set<ll> cs;
        for(ll i=1;i<=n;i++){
            cs.insert(a[i]%l);
            if(cs.size()>3){
                goto nxt;
            }
        }
        sl.insert(l);
        nxt:;
    }
    for(ll i:sl){
        ans+=i;
    }
    std::cout<<ans<<"\n";
}